import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { SRobIslandPlayer } from "../../../../../Message/Game/SRobIslandPlayer";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { PetIslandUtil } from "../PetIslandUtil";
import { RemainTimeUtil } from "../../shopMall/RemainTimeUtil";
import { ObjCreate } from "../../common/ObjCreate";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class PetIslandMemberInfoItemRenderer
    
    export  class PetIslandMemberInfoItemRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        /* internal  */onPositionHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.PetIslandMapShowByPosition, this._vo.pos));
            return;
        }

        /* internal  */onLinkHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            if (this._vo) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetIslandGetPetInfo, this._vo.entityId));
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            if (typeof arg1 === "srobislandplayer") 
            {
                this._vo = arg1 as SRobIslandPlayer;
                this._name.htmlText = Language.getStringByParam(28126, GlobalStyle.dYellowUint, this._vo.name);
                this._life.text = this._vo.life + "/" + this._vo.maxLife;
                this._power.htmlText = GameDefConfig.instance.getPetIslandGuildPosName(this._vo.guildPos);
                this._position.htmlText = PetIslandUtil.getPosition(this._vo, true);
                this._moveTime.text = this._vo.assistTimes.toString();
                if (this._vo.moveCD > 0) 
                {
                    this._enterTime.textColor = GlobalStyle.color7Uint;
                    this._enterTime.text = RemainTimeUtil.getRemainMinute(this._vo.moveCD, true, true, true, false, true);
                }
                else 
                {
                    this._enterTime.textColor = GlobalStyle.color5Uint;
                    this._enterTime.text = "0" + Language.getString(35609);
                }
            }
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc1=GlobalStyle.setTextFormatAlign(GlobalStyle._textFormat2, flash.text.TextFormatAlign.CENTER);
            this._name = ObjCreate.createGTextField("", 0, 5, 105, 20, this, loc1);
            this._life = ObjCreate.createGTextField("", 105, 5, 135, 20, this, loc1);
            this._life.mouseEnabled = false;
            this._power = ObjCreate.createGTextField("", 240, 5, 80, 20, this, loc1);
            this._power.mouseEnabled = false;
            this._position = ObjCreate.createGTextField("", 310, 5, 120, 20, this, GlobalStyle.setTextFormatAlign(GlobalStyle._textFormat1, flash.text.TextFormatAlign.CENTER));
            this._position.addEventListener(flash.events.TextEvent.LINK, this.onPositionHandler);
            this._moveTime = ObjCreate.createGTextField("", 430, 5, 55, 20, this, loc1);
            this._enterTime = ObjCreate.createGTextField("", 493, 5, 60, 20, this, new GTextFormat(FontUtil.songtiName, 12, 11661311, null, null, null, null, null, flash.text.TextFormatAlign.CENTER));
            this._enterTime.mouseEnabled = false;
            this._name.addEventListener(flash.events.TextEvent.LINK, this.onLinkHandler);
            ObjCreate.createBg(3, 27, 550, 2, this, ImagesConst.SplitLine);
            return;
        }

        protected /* override */ initStyle(): void
        {
            var loc1=ObjCreate.createBg(0, 0, 560, 29, null, "Friend_over");
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("downSkin", loc1);
            this.setStyle("overSkin", loc1);
            this.setStyle("selectedDownSkin", loc1);
            this.setStyle("selectedOverSkin", loc1);
            this.setStyle("selectedUpSkin", loc1);
            return;
        }

        /* internal */ /* var */_name: GTextFiled;

        /* internal */ /* var */_life: GTextFiled;

        /* internal */ /* var */_power: GTextFiled;

        /* internal */ /* var */_position: GTextFiled;

        /* internal */ /* var */_moveTime: GTextFiled;

        /* internal */ /* var */_enterTime: GTextFiled;

        /* internal */ /* var */_vo: SRobIslandPlayer;
    }
